// 移动对话框
export function mousedown(e, doc, position) {
  const el = document.getElementById(doc)
  // console.log(e)
  // return
  const disX = e.clientX - el.offsetLeft
  const disY = e.clientY - el.offsetTop
  document.onmousemove = e => {
    const tX = e.clientX - disX
    const tY = e.clientY - disY
    // 移动当前元素
    if (tX >= 0 && tX <= window.innerWidth - el.offsetWidth) {
      if (position == 'left') {
        el.style.left = tX + 'px'
      } else if (position == 'right') {
        el.style.right = tX + 'px'
      }
    }
    if (tY >= 0 && tY <= window.innerHeight - el.offsetHeight) {
      el.style.top = tY + 'px'
    }
  }
}
export function mouseup() {
  document.onmousemove = null
  document.onmouseup = null
}
